package com.mytest.example.asyncservlet.model;

import lombok.Data;

import java.io.Serializable;


@Data
public class ApiResult<T> implements Serializable {
    private Integer code;
    private T data;
    private String message;

    public static <T> ApiResult<T> success(T data) {

        ApiResult<T> result = new ApiResult<>();
        result.setCode(0);
        result.setData(data);
        return result;
    }

    public static ApiResult<Object> fail(String message) {
        ApiResult<Object> result = new ApiResult<>();
        result.setCode(1);
        result.setMessage(message);
        return result;
    }
}
